package club.xinghe.servlet.teacher;

import club.xinghe.biz.ExamBiz;
import club.xinghe.biz.GradeBiz;
import club.xinghe.entity.Exam;
import club.xinghe.entity.Grade;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/teacher/SelectTkServlet")
public class SelectTkServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        int eid = Integer.parseInt(request.getParameter("eid"));
        ExamBiz examBiz = new ExamBiz();
        Exam exam = examBiz.selExzm(eid);
        String estring = exam.geteString();
        int zid=exam.getZy().getzId();

        GradeBiz gradeBiz = new GradeBiz();
        List<Grade> list = gradeBiz.showGrade();

        HttpSession session = request.getSession();
        session.setAttribute("ename",exam.geteName());
        session.setAttribute("estart",exam.geteStart());
        session.setAttribute("eend",exam.geteEnd());
        session.setAttribute("eid",eid);
        session.setAttribute("estring",estring);
        session.setAttribute("zid",zid);
        session.setAttribute("list",list);
        response.sendRedirect("/teacher/SelectTk.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
